<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>学生信息</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!--<link rel="stylesheet" th:href="@{/css/bootstrap.css}">-->
    <!--<script type="text/javascript" th:src="@{/js/jquery-3.5.1.js}"></script>-->
    <!--<script type="text/javascript" th:src="@{/js/bootstrap.js}"></script>-->

</head>
<body>

<p class="h5" style="margin-bottom: 10px;margin-top: 5px"><span class="label label-warning" th:text="${tag}"></span>在此界面您可查看或删除学生信息</p>
<p class="h5" th:if="${studentInfo==null}" style="margin-bottom: 10px;margin-top: 10px">暂无信息</p>

<ul class="list-group" style="margin-top: 30px;" th:each="sInfo:${studentInfo}">
    <li class="list-group-item row list-group-item-warning"><span>学号：</span><span style="margin-right: 30px;" th:text="${sInfo.getStudentId()}"></span><span>姓名：</span><span th:text="${sInfo.getStudentName()}"></span>
        <button th:id="${sInfo.getStudentId()}" class="btn btn-danger" delete style="display:block;float:right;margin-right: 20px;">删除 </button>
    </li>
    <li class="list-group-item row list-group-item-light" >
        <div class="col" style="margin-top: 20px;margin-bottom: 20px;">
            <span class="label label-warning" style="margin-right: 30px;">学院-专业-班级</span>
            <span class="label label-info" th:text="${sInfo.getStudentAcademy()}"> </span>-
            <span class="label label-info" th:text="${sInfo.getStudentMajor()}"> </span>-
            <span class="label label-info" th:text="${sInfo.getStudentClass()}"> </span>
        </div>
        <div class="col" style="margin-top: 8px;" th:each="teacher:${sInfo.getTeachers()}">

           <span class="label label-warning" >课程名：</span><span style="margin-right: 30px;" class="label label-info" th:text="${teacher.getTeacherCourse()}"></span>
           <span class="label label-warning" >任教老师：</span><span style="margin-right: 5px;" class="label label-info" th:text="${teacher.getTeacherName()}"></span>
           <span class="label label-warning" >所属部门：</span><span style="margin-right: 5px;" class="label label-info" th:text="${teacher.getTeacherDepartment()}"></span>
           <span class="label label-warning" >学期批次：</span><span style="margin-right: 5px;" class="label label-info" th:text="${teacher.getTeacherBatch()}"></span>
           <span class="label label-warning" >是否评教：</span><span style="margin-right: 5px;" class="label label-info" th:if="${teacher.getTeacherEvaluateFlag()==1}">已评教</span><span style="margin-right: 5px;" class="label label-info" th:if="${teacher.getTeacherEvaluateFlag()==0}">未评教</span>

        </div>
    </li>
</ul>


<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">提示信息</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <span id="msg-span"> </span>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary  btn-success" data-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {

        // alert("hello world!")
        $("[delete]").click(function () {

            var id = $(this).attr("id");
            console.log(id);


            var data = {
                studentId:id
            };

            $.ajax({
                type: "post",
                url: "/ManagerController/deleteStudent",
                data: JSON.stringify(data),
                datatype: "json",
                contentType: 'application/json',
                async: true,
                success: function (res) {
                    var result = eval('(' + res + ')');
                    $("#msg-span").html(result.value);
                    console.log(result.value);
                    $("#myModal").modal("show");
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $("#msg-span").html("删除失败，出现错误:" + textStatus);
                    $("#myModal").modal("show");
                }
            });


        })

    })

</script>
</body>
</html>